<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="ltr" xmlns="http://www.w3.org/1999/xhtml">
<%@include file="/WEB-INF/taglibs/common/taglibs.jsp"%>
<head>
<title><spring:message code="admin.messagelist.title" /></title>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<link rel="stylesheet" href="<c:url value="/css/styles.css"/>" />
<script type="text/javascript"
	src="<%= request.getContextPath() %>/javascripts/jquery/core/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="<c:url value="/javascripts/common.js"/>"></script>
<script src="<c:url value="/javascripts/common.js"/>" type="text/javascript"></script>
<script type="text/javascript">
	$(document).ready(function() {
		
	
	});
</script>

<script language="javascript" type="text/javascript">
// script added by Umme Essa. The form should be validated on all operations.
	 var functionName="";
	 function validateForm(){
		if(isAnyCheckBoxSelected("selecter")){
			if (confirm("Are you sure you want to delete selected record(s)?"))	return true;
			return false;
		}
			else {
				alert("Please select a record to remove");
				return false;
			}
		
	
	 }

 
	 function isAnyCheckBoxSelected(selecter){
		 var items = document.forms[0].elements[selecter];
		 var length=getLength(items);
		 var item=null;
		 	for(i=0;i<length;i++)
		 	{	item=getItemAt(items,i);
		 		if(item.checked)
		 			return true;
		 	}
		 return false;
		 }

		
		 
	 </script>
</head>

<body><%@include file="../top_menu.jsp"%>

<table width=100%>
	<tr>
		<td><c:import url="/WEB-INF/jsp/menu/admin_messages_menu.jsp" />
		<br />
		</td>
	</tr>
	<tr>
		<td><%@include file="/WEB-INF/jsp/include/messages.jsp"%>
		<br />
		</td>
	</tr>
</table>
<form action="delete.htm" method="post" onsubmit="return validateForm()">
<c:if test="${empty messagesList.pageItems}">
	<tr>
		<td colspan="4"><spring:message code="admin.messagelist.label.nomessageswerefound" /></td>
	</tr>
</c:if> <c:if test="${!empty messagesList.pageItems}">
	<table width=70% class="formTable" cellspacing="0">
		<tr class="ui-state-default">
			<c:if test="${messagesList.pageNumber>1}">
				<td align="left"><a
					href="list.htm?pageNo=${messagesList.pageNumber-1}&sortColumn=${messagesList.sortColumn}"
					class="mouseEffect"><span class="ui-icon ui-icon-seek-prev"
					style="float: left;"></span><spring:message code="admin.messagelist.button.previouspage" /></a></td>
			</c:if>
			<c:if test="${messagesList.pageNumber<messagesList.pagesAvailable}">
				<td align="right"><a
					href="list.htm?pageNo=${messagesList.pageNumber+1}&sortColumn=${messagesList.sortColumn}"
					class="mouseEffect"><span class="ui-icon ui-icon-seek-next"
					style="float: right;"></span><spring:message code="admin.messagelist.button.nextpage" /></a></td>
			</c:if>
		</tr>
	</table>
	<table width=70% class="formTable">
		<tr class="formHeader">
			<td colspan="5"><spring:message code="admin.messagelist.label.messages" /></td>
		</tr>
		<tr>
			<td align="center"><input type="checkbox"
				onclick="ch_select(this.checked)" /></td>
			<th>#</th>
			<th><a	href="list.htm?pageNo=${messagesList.pageNumber}&sortColumn=messageText&sortOrder=${messagesList.sortOrder}"
				class="headerLink" style="cursor: pointer;" title="${messagesList.sortOrder}"><spring:message code="admin.messagelist.label.messagetext" /></a></th>
			<th><spring:message code="admin.messagelist.label.active" /></th>
		</tr>

		<tbody>


			<c:forEach var="r" items="${messagesList.pageItems}" varStatus="i">
				<tr class="tr_record" onmouseover="this.className='highlight'"
					onmouseout="this.className='tr_record'">
					<td align="center" width="25"><input id="selecter"
						type="checkbox" name="ids" value="${r.id}"></input></td>
					<td width="25">${i.count+(messagesList.recordSize*(messagesList.pageNumber-1))}</td>
					<td><a href="edit.htm?id=${r.id}">${r.messageText}</a></td>
					<td>${r.active}</td>
				</tr>
			</c:forEach>

			<tr class="listFooter">
				<td colspan="4"><spring:message code="admin.messagelist.label.foundrecords" arguments="${messagesList.totalRecords}" /></td>
			</tr>
			<tr>
				<td colspan="4"><input type="submit"
					class='ui-button ui-state-default ui-corner-all' value="<spring:message code="admin.messagelist.button.remove" />" /></td>
			</tr>
		</tbody>
	</table>
	<table width=70% class="formTable" cellspacing="0">
		<tr class="ui-state-default">
			<c:if test="${messagesList.pageNumber>1}">
				<td align="left"><a
					href="list.htm?pageNo=${messagesList.pageNumber-1}&sortColumn=${messagesList.sortColumn}"
					class="mouseEffect"><span class="ui-icon ui-icon-seek-prev"
					style="float: left;"></span><spring:message code="admin.messagelist.button.previouspage" /></a></td>
			</c:if>
			<c:if test="${messagesList.pageNumber<messagesList.pagesAvailable}">
				<td align="right"><a
					href="list.htm?pageNo=${messagesList.pageNumber+1}&sortColumn=${messagesList.sortColumn}"
					class="mouseEffect"><span class="ui-icon ui-icon-seek-next"
					style="float: right;"></span><spring:message code="admin.messagelist.button.nextpage" /></a></td>
			</c:if>
		</tr>
	</table>
</c:if></form>
<%@include file="/WEB-INF/jsp/include/footer.jsp"%>
</body>
</html>